var views = chrome.extension.getViews({
    type: 'popup'
});
if (views.length > 0) {
    console.log(views[0].location.href);
}


if (c_box == false || c_box == true) {
    
    if (c_box.checked == false) {
        console.log('false');
    }

    if (c_box.checked == true) {
        console.log('true');
    }

    if (c_box.checked == false) {
        function sendMessageToContentScript(message, callback) {
            chrome.tabs.query({
                active: true,
                currentWindow: true
            }, function (tabs) {
                chrome.tabs.sendMessage(tabs[0].id, message, function (response) {
                    if (callback) callback(response);
                });
            });
        }
        sendMessageToContentScript({
            cmd: 'test',
            cBox: false,
            model_box: model_box.checked,
            time: time.value
        }, function (response) {
            console.log('来自content的回复：' + response);
        });
    }

    if (c_box.checked == true) {
        function sendMessageToContentScript(message, callback) {
            chrome.tabs.query({
                active: true,
                currentWindow: true
            }, function (tabs) {
                chrome.tabs.sendMessage(tabs[0].id, message, function (response) {
                    if (callback) callback(response);
                });
            });
        }
        sendMessageToContentScript({
            cmd: 'test',
            cBox: true,
            model_box: model_box.checked,
            time: time.value
        }, function (response) {
            console.log('来自content的回复：' + response);
        });
    }
}

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse)
{
	console.log('收到来自content-script的消息：');
	console.log(request, sender, sendResponse);
	sendResponse('我是后台，我已收到你的消息：' + JSON.stringify(request));
});